{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "def TECorr(dataFrame, ref):\n",
    "    if ref in dataFrame.Country.unique():\n",
    "        dataFrame = dataFrame[dataFrame.Country == ref[0]]    \n",
    "        dataFrame['DateTime'] = pd.to_datetime(dataFrame['DateTime'])\n",
    "        myReducedDF = dataFrame.pivot(index = 'DateTime', columns='Category', values='Value')\n",
    "        startDate = myReducedDF.tail(1).index[0] - relativedelta(years=5)\n",
    "        myReducedDF = myReducedDF.loc[startDate:]\n",
    "    else:\n",
    "        dataFrame = dataFrame.loc[dataFrame['Category'] == ref[0]]\n",
    "        dataFrame['DateTime'] = pd.to_datetime(dataFrame['DateTime'])\n",
    "        myReducedDF = dataFrame.pivot(index = 'DateTime', columns= 'Country', values='Value')\n",
    "        startDate = myReducedDF.tail(1).index[0] - relativedelta(years=5)\n",
    "        myReducedDF = myReducedDF.loc[startDate:]\n",
    "    del myReducedDF.index.name \n",
    "    del myReducedDF.columns.name\n",
    "    return myReducedDF.corr()"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 2",
   "language": "python",
   "name": "python2"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.13"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
